package j2src;

import java.util.Vector;
import beans.CodeMgnDaoHome;
import beans.CodeMgnDaoRemote;
import beans.CodeMgnDto;



public class CodeMgnDaoDelegate {
	private CodeMgnDaoHome codeMgnDaoHome;
    private CodeMgnDaoRemote codeMgnDaoRemote;
    public CodeMgnDaoDelegate() throws Exception {
    	initializeCodeMgnDaoHome();
    	codeMgnDaoRemote = codeMgnDaoHome.create();
    }
    public Vector getAllCodes() throws Exception{
    	return codeMgnDaoRemote.getAllCodes();
    }
	
	public CodeMgnDto getOneCode(String codeId) throws Exception{
		return codeMgnDaoRemote.getOneCode(codeId);
	}
	
	public boolean insertCode(CodeMgnDto dto) throws Exception{
		return codeMgnDaoRemote.insertCode(dto);
	}
    
    private void initializeCodeMgnDaoHome() throws Exception {
        String FACADE_NAME = "codeMgnDaoBean";
        Class FACADE_CLASS = beans.CodeMgnDaoHome.class;
        if (codeMgnDaoHome == null) {
            try {
                WhiteDaoLocator locator = WhiteDaoLocator.getInstance();
                codeMgnDaoHome = (CodeMgnDaoHome) WhiteDaoLocator.getEjbHome(FACADE_NAME, FACADE_CLASS);
                if (codeMgnDaoHome == null) {
                    throw new Exception("Did not get home for " + FACADE_NAME);
                }
            } catch (WhiteDaoLocatorException e) {
                throw new Exception(e.getMessage());
            }
        }
    }
}
